#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-6-8 17:19
from openpyxl import Workbook


# 处理excel基本操作
def write_excel(file_name, data, excel_head, sheet0_name):
    wb = Workbook()
    # 写入表头
    sheet0 = wb.create_sheet(sheet0_name, index=0)
    for i, item in enumerate(excel_head):
        sheet0.cell(row=1, column=i + 1, value=item)

    # 写入数据
    for i, item in enumerate(data):
        i = i + 2
        for j, val in enumerate(item):
            sheet0.cell(row=i, column=j + 1, value=val)

    wb.save(file_name + '.xlsx')
